﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImportDataFileter.Common
{
    public static class Extensions
    {
        public static string ToString<T>(this IEnumerable<T> source, string separator)
        {
            StringBuilder sb = new StringBuilder();
            foreach (var item in source)
            {
                sb.Append(item).Append(separator);
            }

            if (sb.Length > 0)
                sb.Length -= 1;

            return sb.ToString();
        }

        public static T IsNull<T>(this object source, T defaultValue)
        {
            if (source != null)
                defaultValue = (T)Convert.ChangeType(source, typeof(T));

            return defaultValue;
        }
    }
}
